package com.besttone.adapter;

import java.util.ArrayList;

import com.besttone.search.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CateAdapter extends BaseAdapter
{
	private String[] data;
	Context mContext;
	private LayoutInflater mInflater;
	private int typeIndex = 0;
	
	public CateAdapter(Context context, String[] mChannelArray)
	{
		mContext = context;
		data = mChannelArray;
		this.mInflater = LayoutInflater.from(context);
	}
	
	public String getSelect() {
		return data[typeIndex];
	}
	
	public void setTypeIndex(int index) {
		typeIndex = index;
	}
	

	public int getCount() 
	{
		return data.length;
	}


	public Object getItem(int position) 
	{
		return data[position];
	}


	public long getItemId(int position) 
	{
		return position;
	}


	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.dialog_list_item, null);

		String area = data[position];

		((TextView) convertView.findViewById(R.id.id_area)).setText(area);

		View view = new View(mContext);
		LayoutParams param = new LayoutParams(30, 30);
		view.setLayoutParams(param);

		if (position == typeIndex) {
			convertView.findViewById(R.id.ic_checked).setVisibility(
					View.VISIBLE);
		}
		((LinearLayout) convertView).addView(view, 0);

		return convertView;
	}
	
	private ArrayList<String> getData()
	{
		ArrayList<String> data = new ArrayList<String>();
		data.add("全部频道");
		data.add("美食");
		data.add("休闲娱乐");
		data.add("购物");
		data.add("酒店");
		data.add("丽人");
		data.add("运动健身");
		data.add("结婚");
		data.add("生活服务");
		
		return data;
	}
}